{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "66d27f1c",
   "metadata": {},
   "source": [
    "——————————\n",
    "2022/09/06/week 03\n",
    "python课堂笔记\n",
    "——————————"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7fbc9213",
   "metadata": {},
   "source": [
    "## 本周内容\n",
    "\n",
    "> 1. 回顾变量的概念\n",
    "\n",
    "> 2. 条件判断\n",
    "\n",
    "> 3. for循环和range方法\n",
    "\n",
    "> 4. random模块（伪随机数模块）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a0209b33",
   "metadata": {},
   "outputs": [],
   "source": [
    "网新_01_ID = \"21000001\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "bd8cedab",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'21000001'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网新_01_ID"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cb4cfddc",
   "metadata": {},
   "source": [
    "### 关于模块、变量和if条件判断的课本案例1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a2f09bd5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "现在秒/时间为偶数\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "# 本项目用到了时间模块\n",
    "# print(datetime.datetime.today().microsecond)\n",
    "\n",
    "# odds 是一个变量，后面可以直接使用\n",
    "odds = [  1, 3,  5,  7,  9, 11,13,15,17,19,\n",
    "             21,23,25,27,29,31,33,35,37,39,\n",
    "             41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "# right_this_minute 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "right_this_minute = datetime.datetime.today().second\n",
    "\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(right_this_minute)\n",
    "    print(\"现在是秒/时间为奇数\")\n",
    "else:\n",
    "    print(right_this_minute)\n",
    "    print(\"现在秒/时间为偶数\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "52f7d22e",
   "metadata": {},
   "source": [
    "* 判断当前是一周中的星期几，如果是星期二，看下现在几点了，是python课ing么？然后打印Python课表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "459bec6c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2022, 9, 6)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime\n",
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f48299bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "d298c7ae",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Recover, then rest.\n"
     ]
    }
   ],
   "source": [
    "# 创建today变量(模块获取今天的星期几？)\n",
    "today = \"Sunday\"\n",
    "condition = \"Headache\"\n",
    "\n",
    "\n",
    "if today == \"Saturday\":\n",
    "    print(\"超开心\")\n",
    "elif today ==\"Sunday\":\n",
    "    if condition ==\"Headache\":\n",
    "        print(\"Recover, then rest.\")\n",
    "    else:\n",
    "        print(\"Rest.\")\n",
    "else:\n",
    "    print(\"Work, work, work.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c59f9a0",
   "metadata": {},
   "source": [
    "* 判断当前是一周中的星期几，如果是星期二，看下现在几点了，是python课ing么？然和打印python课表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0ef76e4b",
   "metadata": {},
   "outputs": [],
   "source": [
    "# wkday = 0, 1, 2, 3, 4, 5, 6  分别指周一到周日\n",
    "import time\n",
    "wday = time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "6a172e63",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "13"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime().tm_hour"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "4f135eb7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "45"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime().tm_min"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "e1a64d3e",
   "metadata": {},
   "outputs": [],
   "source": [
    "time_hour = time.localtime().tm_hour"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "27530873",
   "metadata": {},
   "outputs": [],
   "source": [
    "time_min = time.localtime().tm_min"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "3ac6571b",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "正在上python课，大概第二节了\n"
     ]
    }
   ],
   "source": [
    "if wday != 1:\n",
    "    print(\"今天没有python课\")\n",
    "elif time_hour == 12 and time_min > 50:\n",
    "    print(\"正在上python课，刚上课\")\n",
    "elif time_hour == 13:\n",
    "    print(\"正在上python课，大概第二节了\")\n",
    "elif time_hour == 14:\n",
    "    print(\"正在上python课，妈呀，还在上，才2点\")\n",
    "elif time_hour == 15:\n",
    "    print(\"正在上python课，坚持一下，快下课了！\")\n",
    "elif time_hour == 16 and time_min < 50:\n",
    "    print(\"正在上python课，最后一节课了，快下课啦\")\n",
    "else:\n",
    "    print(\"今天有python课，上课时间是下午12.50-16.50\")\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "39d0f0f0",
   "metadata": {},
   "source": [
    "### for循环和range方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6d425482",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "# item 循环遍历\n",
    "for item in [1,2,3]:\n",
    "    print(item)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "d64a2a92",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "210001\n",
      "210002\n",
      "210003\n"
     ]
    }
   ],
   "source": [
    "# 自动生成学号\n",
    "for item in [1,2,3]:\n",
    "    print(item+210000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "739c6677",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# range()自动生成想要的数值，可以控制for循环的次数，一个值，就是从0开始几个数\n",
    "for num in range(5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b3ed8b64",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# range()自动生成想要的数值，可以控制for循环的次数，两个值，从小数（2）开始，大数-小数的个数（5-2）\n",
    "for num in range(2,5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "4add9ff6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "2\n",
      "4\n",
      "6\n",
      "8\n"
     ]
    }
   ],
   "source": [
    "for num in range(0,10,2):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "0df1b302",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/ztb/index0.htm\n",
      "https://www.nfu.edu.cn/ztb/index1.htm\n",
      "https://www.nfu.edu.cn/ztb/index2.htm\n",
      "https://www.nfu.edu.cn/ztb/index3.htm\n",
      "https://www.nfu.edu.cn/ztb/index4.htm\n",
      "https://www.nfu.edu.cn/ztb/index5.htm\n",
      "https://www.nfu.edu.cn/ztb/index6.htm\n",
      "https://www.nfu.edu.cn/ztb/index7.htm\n",
      "https://www.nfu.edu.cn/ztb/index8.htm\n",
      "https://www.nfu.edu.cn/ztb/index9.htm\n",
      "https://www.nfu.edu.cn/ztb/index10.htm\n",
      "https://www.nfu.edu.cn/ztb/index11.htm\n",
      "https://www.nfu.edu.cn/ztb/index12.htm\n",
      "https://www.nfu.edu.cn/ztb/index13.htm\n",
      "https://www.nfu.edu.cn/ztb/index14.htm\n",
      "https://www.nfu.edu.cn/ztb/index15.htm\n",
      "https://www.nfu.edu.cn/ztb/index16.htm\n",
      "https://www.nfu.edu.cn/ztb/index17.htm\n",
      "https://www.nfu.edu.cn/ztb/index18.htm\n",
      "https://www.nfu.edu.cn/ztb/index19.htm\n",
      "https://www.nfu.edu.cn/ztb/index20.htm\n",
      "https://www.nfu.edu.cn/ztb/index21.htm\n",
      "https://www.nfu.edu.cn/ztb/index22.htm\n",
      "https://www.nfu.edu.cn/ztb/index23.htm\n",
      "https://www.nfu.edu.cn/ztb/index24.htm\n",
      "https://www.nfu.edu.cn/ztb/index25.htm\n",
      "https://www.nfu.edu.cn/ztb/index26.htm\n"
     ]
    }
   ],
   "source": [
    "中大南方_招投标 = \"https//www.nfu.edu.cn/ztb/index.htm\"\n",
    "for page in range(27):\n",
    "    print(\"https://www.nfu.edu.cn/ztb/index\" + str(page) + \".htm\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7b242df5",
   "metadata": {},
   "source": [
    "### random模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "d1af035a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "407718ec",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.32846180864382024"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "44f3d388",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6\n",
      "6\n",
      "2\n",
      "5\n",
      "6\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(random.randint(1,6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "d258a278",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on module random:\n",
      "\n",
      "NAME\n",
      "    random - Random variable generators.\n",
      "\n",
      "MODULE REFERENCE\n",
      "    https://docs.python.org/3.9/library/random\n",
      "    \n",
      "    The following documentation is automatically generated from the Python\n",
      "    source files.  It may be incomplete, incorrect or include features that\n",
      "    are considered implementation detail and may vary between Python\n",
      "    implementations.  When in doubt, consult the module reference at the\n",
      "    location listed above.\n",
      "\n",
      "DESCRIPTION\n",
      "        bytes\n",
      "        -----\n",
      "               uniform bytes (values between 0 and 255)\n",
      "    \n",
      "        integers\n",
      "        --------\n",
      "               uniform within range\n",
      "    \n",
      "        sequences\n",
      "        ---------\n",
      "               pick random element\n",
      "               pick random sample\n",
      "               pick weighted random sample\n",
      "               generate random permutation\n",
      "    \n",
      "        distributions on the real line:\n",
      "        ------------------------------\n",
      "               uniform\n",
      "               triangular\n",
      "               normal (Gaussian)\n",
      "               lognormal\n",
      "               negative exponential\n",
      "               gamma\n",
      "               beta\n",
      "               pareto\n",
      "               Weibull\n",
      "    \n",
      "        distributions on the circle (angles 0 to 2pi)\n",
      "        ---------------------------------------------\n",
      "               circular uniform\n",
      "               von Mises\n",
      "    \n",
      "    General notes on the underlying Mersenne Twister core generator:\n",
      "    \n",
      "    * The period is 2**19937-1.\n",
      "    * It is one of the most extensively tested generators in existence.\n",
      "    * The random() method is implemented in C, executes in a single Python step,\n",
      "      and is, therefore, threadsafe.\n",
      "\n",
      "CLASSES\n",
      "    _random.Random(builtins.object)\n",
      "        Random\n",
      "            SystemRandom\n",
      "    \n",
      "    class Random(_random.Random)\n",
      "     |  Random(x=None)\n",
      "     |  \n",
      "     |  Random number generator base class used by bound module functions.\n",
      "     |  \n",
      "     |  Used to instantiate instances of Random to get generators that don't\n",
      "     |  share state.\n",
      "     |  \n",
      "     |  Class Random can also be subclassed if you want to use a different basic\n",
      "     |  generator of your own devising: in that case, override the following\n",
      "     |  methods:  random(), seed(), getstate(), and setstate().\n",
      "     |  Optionally, implement a getrandbits() method so that randrange()\n",
      "     |  can cover arbitrarily large ranges.\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      Random\n",
      "     |      _random.Random\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __getstate__(self)\n",
      "     |      # Issue 17489: Since __reduce__ was defined to fix #759889 this is no\n",
      "     |      # longer called; we leave it here because it has been here since random was\n",
      "     |      # rewritten back in 2001 and why risk breaking something.\n",
      "     |  \n",
      "     |  __init__(self, x=None)\n",
      "     |      Initialize an instance.\n",
      "     |      \n",
      "     |      Optional argument x controls seeding, as for Random.seed().\n",
      "     |  \n",
      "     |  __reduce__(self)\n",
      "     |      Helper for pickle.\n",
      "     |  \n",
      "     |  __setstate__(self, state)\n",
      "     |  \n",
      "     |  betavariate(self, alpha, beta)\n",
      "     |      Beta distribution.\n",
      "     |      \n",
      "     |      Conditions on the parameters are alpha > 0 and beta > 0.\n",
      "     |      Returned values range between 0 and 1.\n",
      "     |  \n",
      "     |  choice(self, seq)\n",
      "     |      Choose a random element from a non-empty sequence.\n",
      "     |  \n",
      "     |  choices(self, population, weights=None, *, cum_weights=None, k=1)\n",
      "     |      Return a k sized list of population elements chosen with replacement.\n",
      "     |      \n",
      "     |      If the relative weights or cumulative weights are not specified,\n",
      "     |      the selections are made with equal probability.\n",
      "     |  \n",
      "     |  expovariate(self, lambd)\n",
      "     |      Exponential distribution.\n",
      "     |      \n",
      "     |      lambd is 1.0 divided by the desired mean.  It should be\n",
      "     |      nonzero.  (The parameter would be called \"lambda\", but that is\n",
      "     |      a reserved word in Python.)  Returned values range from 0 to\n",
      "     |      positive infinity if lambd is positive, and from negative\n",
      "     |      infinity to 0 if lambd is negative.\n",
      "     |  \n",
      "     |  gammavariate(self, alpha, beta)\n",
      "     |      Gamma distribution.  Not the gamma function!\n",
      "     |      \n",
      "     |      Conditions on the parameters are alpha > 0 and beta > 0.\n",
      "     |      \n",
      "     |      The probability distribution function is:\n",
      "     |      \n",
      "     |                  x ** (alpha - 1) * math.exp(-x / beta)\n",
      "     |        pdf(x) =  --------------------------------------\n",
      "     |                    math.gamma(alpha) * beta ** alpha\n",
      "     |  \n",
      "     |  gauss(self, mu, sigma)\n",
      "     |      Gaussian distribution.\n",
      "     |      \n",
      "     |      mu is the mean, and sigma is the standard deviation.  This is\n",
      "     |      slightly faster than the normalvariate() function.\n",
      "     |      \n",
      "     |      Not thread-safe without a lock around calls.\n",
      "     |  \n",
      "     |  getstate(self)\n",
      "     |      Return internal state; can be passed to setstate() later.\n",
      "     |  \n",
      "     |  lognormvariate(self, mu, sigma)\n",
      "     |      Log normal distribution.\n",
      "     |      \n",
      "     |      If you take the natural logarithm of this distribution, you'll get a\n",
      "     |      normal distribution with mean mu and standard deviation sigma.\n",
      "     |      mu can have any value, and sigma must be greater than zero.\n",
      "     |  \n",
      "     |  normalvariate(self, mu, sigma)\n",
      "     |      Normal distribution.\n",
      "     |      \n",
      "     |      mu is the mean, and sigma is the standard deviation.\n",
      "     |  \n",
      "     |  paretovariate(self, alpha)\n",
      "     |      Pareto distribution.  alpha is the shape parameter.\n",
      "     |  \n",
      "     |  randbytes(self, n)\n",
      "     |      Generate n random bytes.\n",
      "     |  \n",
      "     |  randint(self, a, b)\n",
      "     |      Return random integer in range [a, b], including both end points.\n",
      "     |  \n",
      "     |  randrange(self, start, stop=None, step=1)\n",
      "     |      Choose a random item from range(start, stop[, step]).\n",
      "     |      \n",
      "     |      This fixes the problem with randint() which includes the\n",
      "     |      endpoint; in Python this is usually not what you want.\n",
      "     |  \n",
      "     |  sample(self, population, k, *, counts=None)\n",
      "     |      Chooses k unique random elements from a population sequence or set.\n",
      "     |      \n",
      "     |      Returns a new list containing elements from the population while\n",
      "     |      leaving the original population unchanged.  The resulting list is\n",
      "     |      in selection order so that all sub-slices will also be valid random\n",
      "     |      samples.  This allows raffle winners (the sample) to be partitioned\n",
      "     |      into grand prize and second place winners (the subslices).\n",
      "     |      \n",
      "     |      Members of the population need not be hashable or unique.  If the\n",
      "     |      population contains repeats, then each occurrence is a possible\n",
      "     |      selection in the sample.\n",
      "     |      \n",
      "     |      Repeated elements can be specified one at a time or with the optional\n",
      "     |      counts parameter.  For example:\n",
      "     |      \n",
      "     |          sample(['red', 'blue'], counts=[4, 2], k=5)\n",
      "     |      \n",
      "     |      is equivalent to:\n",
      "     |      \n",
      "     |          sample(['red', 'red', 'red', 'red', 'blue', 'blue'], k=5)\n",
      "     |      \n",
      "     |      To choose a sample from a range of integers, use range() for the\n",
      "     |      population argument.  This is especially fast and space efficient\n",
      "     |      for sampling from a large population:\n",
      "     |      \n",
      "     |          sample(range(10000000), 60)\n",
      "     |  \n",
      "     |  seed(self, a=None, version=2)\n",
      "     |      Initialize internal state from a seed.\n",
      "     |      \n",
      "     |      The only supported seed types are None, int, float,\n",
      "     |      str, bytes, and bytearray.\n",
      "     |      \n",
      "     |      None or no argument seeds from current time or from an operating\n",
      "     |      system specific randomness source if available.\n",
      "     |      \n",
      "     |      If *a* is an int, all bits are used.\n",
      "     |      \n",
      "     |      For version 2 (the default), all of the bits are used if *a* is a str,\n",
      "     |      bytes, or bytearray.  For version 1 (provided for reproducing random\n",
      "     |      sequences from older versions of Python), the algorithm for str and\n",
      "     |      bytes generates a narrower range of seeds.\n",
      "     |  \n",
      "     |  setstate(self, state)\n",
      "     |      Restore internal state from object returned by getstate().\n",
      "     |  \n",
      "     |  shuffle(self, x, random=None)\n",
      "     |      Shuffle list x in place, and return None.\n",
      "     |      \n",
      "     |      Optional argument random is a 0-argument function returning a\n",
      "     |      random float in [0.0, 1.0); if it is the default None, the\n",
      "     |      standard random.random will be used.\n",
      "     |  \n",
      "     |  triangular(self, low=0.0, high=1.0, mode=None)\n",
      "     |      Triangular distribution.\n",
      "     |      \n",
      "     |      Continuous distribution bounded by given lower and upper limits,\n",
      "     |      and having a given mode value in-between.\n",
      "     |      \n",
      "     |      http://en.wikipedia.org/wiki/Triangular_distribution\n",
      "     |  \n",
      "     |  uniform(self, a, b)\n",
      "     |      Get a random number in the range [a, b) or [a, b] depending on rounding.\n",
      "     |  \n",
      "     |  vonmisesvariate(self, mu, kappa)\n",
      "     |      Circular data distribution.\n",
      "     |      \n",
      "     |      mu is the mean angle, expressed in radians between 0 and 2*pi, and\n",
      "     |      kappa is the concentration parameter, which must be greater than or\n",
      "     |      equal to zero.  If kappa is equal to zero, this distribution reduces\n",
      "     |      to a uniform random angle over the range 0 to 2*pi.\n",
      "     |  \n",
      "     |  weibullvariate(self, alpha, beta)\n",
      "     |      Weibull distribution.\n",
      "     |      \n",
      "     |      alpha is the scale parameter and beta is the shape parameter.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Class methods defined here:\n",
      "     |  \n",
      "     |  __init_subclass__(**kwargs) from builtins.type\n",
      "     |      Control how subclasses generate random integers.\n",
      "     |      \n",
      "     |      The algorithm a subclass can use depends on the random() and/or\n",
      "     |      getrandbits() implementation available to it and determines\n",
      "     |      whether it can generate random integers from arbitrarily large\n",
      "     |      ranges.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  __dict__\n",
      "     |      dictionary for instance variables (if defined)\n",
      "     |  \n",
      "     |  __weakref__\n",
      "     |      list of weak references to the object (if defined)\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes defined here:\n",
      "     |  \n",
      "     |  VERSION = 3\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from _random.Random:\n",
      "     |  \n",
      "     |  getrandbits(self, k, /)\n",
      "     |      getrandbits(k) -> x.  Generates an int with k random bits.\n",
      "     |  \n",
      "     |  random(self, /)\n",
      "     |      random() -> x in the interval [0, 1).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods inherited from _random.Random:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "    \n",
      "    class SystemRandom(Random)\n",
      "     |  SystemRandom(x=None)\n",
      "     |  \n",
      "     |  Alternate random number generator using sources provided\n",
      "     |  by the operating system (such as /dev/urandom on Unix or\n",
      "     |  CryptGenRandom on Windows).\n",
      "     |  \n",
      "     |   Not available on all systems (see os.urandom() for details).\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      SystemRandom\n",
      "     |      Random\n",
      "     |      _random.Random\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  getrandbits(self, k)\n",
      "     |      getrandbits(k) -> x.  Generates an int with k random bits.\n",
      "     |  \n",
      "     |  getstate = _notimplemented(self, *args, **kwds)\n",
      "     |  \n",
      "     |  randbytes(self, n)\n",
      "     |      Generate n random bytes.\n",
      "     |  \n",
      "     |  random(self)\n",
      "     |      Get the next random number in the range [0.0, 1.0).\n",
      "     |  \n",
      "     |  seed(self, *args, **kwds)\n",
      "     |      Stub method.  Not used for a system random number generator.\n",
      "     |  \n",
      "     |  setstate = _notimplemented(self, *args, **kwds)\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from Random:\n",
      "     |  \n",
      "     |  __getstate__(self)\n",
      "     |      # Issue 17489: Since __reduce__ was defined to fix #759889 this is no\n",
      "     |      # longer called; we leave it here because it has been here since random was\n",
      "     |      # rewritten back in 2001 and why risk breaking something.\n",
      "     |  \n",
      "     |  __init__(self, x=None)\n",
      "     |      Initialize an instance.\n",
      "     |      \n",
      "     |      Optional argument x controls seeding, as for Random.seed().\n",
      "     |  \n",
      "     |  __reduce__(self)\n",
      "     |      Helper for pickle.\n",
      "     |  \n",
      "     |  __setstate__(self, state)\n",
      "     |  \n",
      "     |  betavariate(self, alpha, beta)\n",
      "     |      Beta distribution.\n",
      "     |      \n",
      "     |      Conditions on the parameters are alpha > 0 and beta > 0.\n",
      "     |      Returned values range between 0 and 1.\n",
      "     |  \n",
      "     |  choice(self, seq)\n",
      "     |      Choose a random element from a non-empty sequence.\n",
      "     |  \n",
      "     |  choices(self, population, weights=None, *, cum_weights=None, k=1)\n",
      "     |      Return a k sized list of population elements chosen with replacement.\n",
      "     |      \n",
      "     |      If the relative weights or cumulative weights are not specified,\n",
      "     |      the selections are made with equal probability.\n",
      "     |  \n",
      "     |  expovariate(self, lambd)\n",
      "     |      Exponential distribution.\n",
      "     |      \n",
      "     |      lambd is 1.0 divided by the desired mean.  It should be\n",
      "     |      nonzero.  (The parameter would be called \"lambda\", but that is\n",
      "     |      a reserved word in Python.)  Returned values range from 0 to\n",
      "     |      positive infinity if lambd is positive, and from negative\n",
      "     |      infinity to 0 if lambd is negative.\n",
      "     |  \n",
      "     |  gammavariate(self, alpha, beta)\n",
      "     |      Gamma distribution.  Not the gamma function!\n",
      "     |      \n",
      "     |      Conditions on the parameters are alpha > 0 and beta > 0.\n",
      "     |      \n",
      "     |      The probability distribution function is:\n",
      "     |      \n",
      "     |                  x ** (alpha - 1) * math.exp(-x / beta)\n",
      "     |        pdf(x) =  --------------------------------------\n",
      "     |                    math.gamma(alpha) * beta ** alpha\n",
      "     |  \n",
      "     |  gauss(self, mu, sigma)\n",
      "     |      Gaussian distribution.\n",
      "     |      \n",
      "     |      mu is the mean, and sigma is the standard deviation.  This is\n",
      "     |      slightly faster than the normalvariate() function.\n",
      "     |      \n",
      "     |      Not thread-safe without a lock around calls.\n",
      "     |  \n",
      "     |  lognormvariate(self, mu, sigma)\n",
      "     |      Log normal distribution.\n",
      "     |      \n",
      "     |      If you take the natural logarithm of this distribution, you'll get a\n",
      "     |      normal distribution with mean mu and standard deviation sigma.\n",
      "     |      mu can have any value, and sigma must be greater than zero.\n",
      "     |  \n",
      "     |  normalvariate(self, mu, sigma)\n",
      "     |      Normal distribution.\n",
      "     |      \n",
      "     |      mu is the mean, and sigma is the standard deviation.\n",
      "     |  \n",
      "     |  paretovariate(self, alpha)\n",
      "     |      Pareto distribution.  alpha is the shape parameter.\n",
      "     |  \n",
      "     |  randint(self, a, b)\n",
      "     |      Return random integer in range [a, b], including both end points.\n",
      "     |  \n",
      "     |  randrange(self, start, stop=None, step=1)\n",
      "     |      Choose a random item from range(start, stop[, step]).\n",
      "     |      \n",
      "     |      This fixes the problem with randint() which includes the\n",
      "     |      endpoint; in Python this is usually not what you want.\n",
      "     |  \n",
      "     |  sample(self, population, k, *, counts=None)\n",
      "     |      Chooses k unique random elements from a population sequence or set.\n",
      "     |      \n",
      "     |      Returns a new list containing elements from the population while\n",
      "     |      leaving the original population unchanged.  The resulting list is\n",
      "     |      in selection order so that all sub-slices will also be valid random\n",
      "     |      samples.  This allows raffle winners (the sample) to be partitioned\n",
      "     |      into grand prize and second place winners (the subslices).\n",
      "     |      \n",
      "     |      Members of the population need not be hashable or unique.  If the\n",
      "     |      population contains repeats, then each occurrence is a possible\n",
      "     |      selection in the sample.\n",
      "     |      \n",
      "     |      Repeated elements can be specified one at a time or with the optional\n",
      "     |      counts parameter.  For example:\n",
      "     |      \n",
      "     |          sample(['red', 'blue'], counts=[4, 2], k=5)\n",
      "     |      \n",
      "     |      is equivalent to:\n",
      "     |      \n",
      "     |          sample(['red', 'red', 'red', 'red', 'blue', 'blue'], k=5)\n",
      "     |      \n",
      "     |      To choose a sample from a range of integers, use range() for the\n",
      "     |      population argument.  This is especially fast and space efficient\n",
      "     |      for sampling from a large population:\n",
      "     |      \n",
      "     |          sample(range(10000000), 60)\n",
      "     |  \n",
      "     |  shuffle(self, x, random=None)\n",
      "     |      Shuffle list x in place, and return None.\n",
      "     |      \n",
      "     |      Optional argument random is a 0-argument function returning a\n",
      "     |      random float in [0.0, 1.0); if it is the default None, the\n",
      "     |      standard random.random will be used.\n",
      "     |  \n",
      "     |  triangular(self, low=0.0, high=1.0, mode=None)\n",
      "     |      Triangular distribution.\n",
      "     |      \n",
      "     |      Continuous distribution bounded by given lower and upper limits,\n",
      "     |      and having a given mode value in-between.\n",
      "     |      \n",
      "     |      http://en.wikipedia.org/wiki/Triangular_distribution\n",
      "     |  \n",
      "     |  uniform(self, a, b)\n",
      "     |      Get a random number in the range [a, b) or [a, b] depending on rounding.\n",
      "     |  \n",
      "     |  vonmisesvariate(self, mu, kappa)\n",
      "     |      Circular data distribution.\n",
      "     |      \n",
      "     |      mu is the mean angle, expressed in radians between 0 and 2*pi, and\n",
      "     |      kappa is the concentration parameter, which must be greater than or\n",
      "     |      equal to zero.  If kappa is equal to zero, this distribution reduces\n",
      "     |      to a uniform random angle over the range 0 to 2*pi.\n",
      "     |  \n",
      "     |  weibullvariate(self, alpha, beta)\n",
      "     |      Weibull distribution.\n",
      "     |      \n",
      "     |      alpha is the scale parameter and beta is the shape parameter.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Class methods inherited from Random:\n",
      "     |  \n",
      "     |  __init_subclass__(**kwargs) from builtins.type\n",
      "     |      Control how subclasses generate random integers.\n",
      "     |      \n",
      "     |      The algorithm a subclass can use depends on the random() and/or\n",
      "     |      getrandbits() implementation available to it and determines\n",
      "     |      whether it can generate random integers from arbitrarily large\n",
      "     |      ranges.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors inherited from Random:\n",
      "     |  \n",
      "     |  __dict__\n",
      "     |      dictionary for instance variables (if defined)\n",
      "     |  \n",
      "     |  __weakref__\n",
      "     |      list of weak references to the object (if defined)\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes inherited from Random:\n",
      "     |  \n",
      "     |  VERSION = 3\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods inherited from _random.Random:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "\n",
      "FUNCTIONS\n",
      "    betavariate(alpha, beta) method of Random instance\n",
      "        Beta distribution.\n",
      "        \n",
      "        Conditions on the parameters are alpha > 0 and beta > 0.\n",
      "        Returned values range between 0 and 1.\n",
      "    \n",
      "    choice(seq) method of Random instance\n",
      "        Choose a random element from a non-empty sequence.\n",
      "    \n",
      "    choices(population, weights=None, *, cum_weights=None, k=1) method of Random instance\n",
      "        Return a k sized list of population elements chosen with replacement.\n",
      "        \n",
      "        If the relative weights or cumulative weights are not specified,\n",
      "        the selections are made with equal probability.\n",
      "    \n",
      "    expovariate(lambd) method of Random instance\n",
      "        Exponential distribution.\n",
      "        \n",
      "        lambd is 1.0 divided by the desired mean.  It should be\n",
      "        nonzero.  (The parameter would be called \"lambda\", but that is\n",
      "        a reserved word in Python.)  Returned values range from 0 to\n",
      "        positive infinity if lambd is positive, and from negative\n",
      "        infinity to 0 if lambd is negative.\n",
      "    \n",
      "    gammavariate(alpha, beta) method of Random instance\n",
      "        Gamma distribution.  Not the gamma function!\n",
      "        \n",
      "        Conditions on the parameters are alpha > 0 and beta > 0.\n",
      "        \n",
      "        The probability distribution function is:\n",
      "        \n",
      "                    x ** (alpha - 1) * math.exp(-x / beta)\n",
      "          pdf(x) =  --------------------------------------\n",
      "                      math.gamma(alpha) * beta ** alpha\n",
      "    \n",
      "    gauss(mu, sigma) method of Random instance\n",
      "        Gaussian distribution.\n",
      "        \n",
      "        mu is the mean, and sigma is the standard deviation.  This is\n",
      "        slightly faster than the normalvariate() function.\n",
      "        \n",
      "        Not thread-safe without a lock around calls.\n",
      "    \n",
      "    getrandbits(k, /) method of Random instance\n",
      "        getrandbits(k) -> x.  Generates an int with k random bits.\n",
      "    \n",
      "    getstate() method of Random instance\n",
      "        Return internal state; can be passed to setstate() later.\n",
      "    \n",
      "    lognormvariate(mu, sigma) method of Random instance\n",
      "        Log normal distribution.\n",
      "        \n",
      "        If you take the natural logarithm of this distribution, you'll get a\n",
      "        normal distribution with mean mu and standard deviation sigma.\n",
      "        mu can have any value, and sigma must be greater than zero.\n",
      "    \n",
      "    normalvariate(mu, sigma) method of Random instance\n",
      "        Normal distribution.\n",
      "        \n",
      "        mu is the mean, and sigma is the standard deviation.\n",
      "    \n",
      "    paretovariate(alpha) method of Random instance\n",
      "        Pareto distribution.  alpha is the shape parameter.\n",
      "    \n",
      "    randbytes(n) method of Random instance\n",
      "        Generate n random bytes.\n",
      "    \n",
      "    randint(a, b) method of Random instance\n",
      "        Return random integer in range [a, b], including both end points.\n",
      "    \n",
      "    random() method of Random instance\n",
      "        random() -> x in the interval [0, 1).\n",
      "    \n",
      "    randrange(start, stop=None, step=1) method of Random instance\n",
      "        Choose a random item from range(start, stop[, step]).\n",
      "        \n",
      "        This fixes the problem with randint() which includes the\n",
      "        endpoint; in Python this is usually not what you want.\n",
      "    \n",
      "    sample(population, k, *, counts=None) method of Random instance\n",
      "        Chooses k unique random elements from a population sequence or set.\n",
      "        \n",
      "        Returns a new list containing elements from the population while\n",
      "        leaving the original population unchanged.  The resulting list is\n",
      "        in selection order so that all sub-slices will also be valid random\n",
      "        samples.  This allows raffle winners (the sample) to be partitioned\n",
      "        into grand prize and second place winners (the subslices).\n",
      "        \n",
      "        Members of the population need not be hashable or unique.  If the\n",
      "        population contains repeats, then each occurrence is a possible\n",
      "        selection in the sample.\n",
      "        \n",
      "        Repeated elements can be specified one at a time or with the optional\n",
      "        counts parameter.  For example:\n",
      "        \n",
      "            sample(['red', 'blue'], counts=[4, 2], k=5)\n",
      "        \n",
      "        is equivalent to:\n",
      "        \n",
      "            sample(['red', 'red', 'red', 'red', 'blue', 'blue'], k=5)\n",
      "        \n",
      "        To choose a sample from a range of integers, use range() for the\n",
      "        population argument.  This is especially fast and space efficient\n",
      "        for sampling from a large population:\n",
      "        \n",
      "            sample(range(10000000), 60)\n",
      "    \n",
      "    seed(a=None, version=2) method of Random instance\n",
      "        Initialize internal state from a seed.\n",
      "        \n",
      "        The only supported seed types are None, int, float,\n",
      "        str, bytes, and bytearray.\n",
      "        \n",
      "        None or no argument seeds from current time or from an operating\n",
      "        system specific randomness source if available.\n",
      "        \n",
      "        If *a* is an int, all bits are used.\n",
      "        \n",
      "        For version 2 (the default), all of the bits are used if *a* is a str,\n",
      "        bytes, or bytearray.  For version 1 (provided for reproducing random\n",
      "        sequences from older versions of Python), the algorithm for str and\n",
      "        bytes generates a narrower range of seeds.\n",
      "    \n",
      "    setstate(state) method of Random instance\n",
      "        Restore internal state from object returned by getstate().\n",
      "    \n",
      "    shuffle(x, random=None) method of Random instance\n",
      "        Shuffle list x in place, and return None.\n",
      "        \n",
      "        Optional argument random is a 0-argument function returning a\n",
      "        random float in [0.0, 1.0); if it is the default None, the\n",
      "        standard random.random will be used.\n",
      "    \n",
      "    triangular(low=0.0, high=1.0, mode=None) method of Random instance\n",
      "        Triangular distribution.\n",
      "        \n",
      "        Continuous distribution bounded by given lower and upper limits,\n",
      "        and having a given mode value in-between.\n",
      "        \n",
      "        http://en.wikipedia.org/wiki/Triangular_distribution\n",
      "    \n",
      "    uniform(a, b) method of Random instance\n",
      "        Get a random number in the range [a, b) or [a, b] depending on rounding.\n",
      "    \n",
      "    vonmisesvariate(mu, kappa) method of Random instance\n",
      "        Circular data distribution.\n",
      "        \n",
      "        mu is the mean angle, expressed in radians between 0 and 2*pi, and\n",
      "        kappa is the concentration parameter, which must be greater than or\n",
      "        equal to zero.  If kappa is equal to zero, this distribution reduces\n",
      "        to a uniform random angle over the range 0 to 2*pi.\n",
      "    \n",
      "    weibullvariate(alpha, beta) method of Random instance\n",
      "        Weibull distribution.\n",
      "        \n",
      "        alpha is the scale parameter and beta is the shape parameter.\n",
      "\n",
      "DATA\n",
      "    __all__ = ['Random', 'SystemRandom', 'betavariate', 'choice', 'choices...\n",
      "\n",
      "FILE\n",
      "    e:\\anaconda\\lib\\random.py\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "73100faf",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "251d2f9c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world\n"
     ]
    }
   ],
   "source": [
    "time.sleep(3)\n",
    "print(\"hello world\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5a02dbc7",
   "metadata": {},
   "source": [
    "# 课本43实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "08b846ec",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles 在啤酒墙上\n",
      "99 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "98 bottles 在啤酒墙上\n",
      "98 bottles 在啤酒墙上\n",
      "98 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "97 bottles 在啤酒墙上\n",
      "97 bottles 在啤酒墙上\n",
      "97 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "96 bottles 在啤酒墙上\n",
      "96 bottles 在啤酒墙上\n",
      "96 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "95 bottles 在啤酒墙上\n",
      "95 bottles 在啤酒墙上\n",
      "95 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "94 bottles 在啤酒墙上\n",
      "94 bottles 在啤酒墙上\n",
      "94 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "93 bottles 在啤酒墙上\n",
      "93 bottles 在啤酒墙上\n",
      "93 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "92 bottles 在啤酒墙上\n",
      "92 bottles 在啤酒墙上\n",
      "92 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "91 bottles 在啤酒墙上\n",
      "91 bottles 在啤酒墙上\n",
      "91 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "90 bottles 在啤酒墙上\n",
      "90 bottles 在啤酒墙上\n",
      "90 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "89 bottles 在啤酒墙上\n",
      "89 bottles 在啤酒墙上\n",
      "89 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "88 bottles 在啤酒墙上\n",
      "88 bottles 在啤酒墙上\n",
      "88 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "87 bottles 在啤酒墙上\n",
      "87 bottles 在啤酒墙上\n",
      "87 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "86 bottles 在啤酒墙上\n",
      "86 bottles 在啤酒墙上\n",
      "86 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "85 bottles 在啤酒墙上\n",
      "85 bottles 在啤酒墙上\n",
      "85 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "84 bottles 在啤酒墙上\n",
      "84 bottles 在啤酒墙上\n",
      "84 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "83 bottles 在啤酒墙上\n",
      "83 bottles 在啤酒墙上\n",
      "83 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "82 bottles 在啤酒墙上\n",
      "82 bottles 在啤酒墙上\n",
      "82 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "81 bottles 在啤酒墙上\n",
      "81 bottles 在啤酒墙上\n",
      "81 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "80 bottles 在啤酒墙上\n",
      "80 bottles 在啤酒墙上\n",
      "80 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "79 bottles 在啤酒墙上\n",
      "79 bottles 在啤酒墙上\n",
      "79 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "78 bottles 在啤酒墙上\n",
      "78 bottles 在啤酒墙上\n",
      "78 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "77 bottles 在啤酒墙上\n",
      "77 bottles 在啤酒墙上\n",
      "77 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "76 bottles 在啤酒墙上\n",
      "76 bottles 在啤酒墙上\n",
      "76 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "75 bottles 在啤酒墙上\n",
      "75 bottles 在啤酒墙上\n",
      "75 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "74 bottles 在啤酒墙上\n",
      "74 bottles 在啤酒墙上\n",
      "74 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "73 bottles 在啤酒墙上\n",
      "73 bottles 在啤酒墙上\n",
      "73 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "72 bottles 在啤酒墙上\n",
      "72 bottles 在啤酒墙上\n",
      "72 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "71 bottles 在啤酒墙上\n",
      "71 bottles 在啤酒墙上\n",
      "71 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "70 bottles 在啤酒墙上\n",
      "70 bottles 在啤酒墙上\n",
      "70 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "69 bottles 在啤酒墙上\n",
      "69 bottles 在啤酒墙上\n",
      "69 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "68 bottles 在啤酒墙上\n",
      "68 bottles 在啤酒墙上\n",
      "68 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "67 bottles 在啤酒墙上\n",
      "67 bottles 在啤酒墙上\n",
      "67 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "66 bottles 在啤酒墙上\n",
      "66 bottles 在啤酒墙上\n",
      "66 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "65 bottles 在啤酒墙上\n",
      "65 bottles 在啤酒墙上\n",
      "65 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "64 bottles 在啤酒墙上\n",
      "64 bottles 在啤酒墙上\n",
      "64 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "63 bottles 在啤酒墙上\n",
      "63 bottles 在啤酒墙上\n",
      "63 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "62 bottles 在啤酒墙上\n",
      "62 bottles 在啤酒墙上\n",
      "62 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "61 bottles 在啤酒墙上\n",
      "61 bottles 在啤酒墙上\n",
      "61 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "60 bottles 在啤酒墙上\n",
      "60 bottles 在啤酒墙上\n",
      "60 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "59 bottles 在啤酒墙上\n",
      "59 bottles 在啤酒墙上\n",
      "59 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "58 bottles 在啤酒墙上\n",
      "58 bottles 在啤酒墙上\n",
      "58 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "57 bottles 在啤酒墙上\n",
      "57 bottles 在啤酒墙上\n",
      "57 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "56 bottles 在啤酒墙上\n",
      "56 bottles 在啤酒墙上\n",
      "56 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "55 bottles 在啤酒墙上\n",
      "55 bottles 在啤酒墙上\n",
      "55 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "54 bottles 在啤酒墙上\n",
      "54 bottles 在啤酒墙上\n",
      "54 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "53 bottles 在啤酒墙上\n",
      "53 bottles 在啤酒墙上\n",
      "53 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "52 bottles 在啤酒墙上\n",
      "52 bottles 在啤酒墙上\n",
      "52 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "51 bottles 在啤酒墙上\n",
      "51 bottles 在啤酒墙上\n",
      "51 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "50 bottles 在啤酒墙上\n",
      "50 bottles 在啤酒墙上\n",
      "50 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "49 bottles 在啤酒墙上\n",
      "49 bottles 在啤酒墙上\n",
      "49 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "48 bottles 在啤酒墙上\n",
      "48 bottles 在啤酒墙上\n",
      "48 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "47 bottles 在啤酒墙上\n",
      "47 bottles 在啤酒墙上\n",
      "47 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "46 bottles 在啤酒墙上\n",
      "46 bottles 在啤酒墙上\n",
      "46 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "45 bottles 在啤酒墙上\n",
      "45 bottles 在啤酒墙上\n",
      "45 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "44 bottles 在啤酒墙上\n",
      "44 bottles 在啤酒墙上\n",
      "44 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "43 bottles 在啤酒墙上\n",
      "43 bottles 在啤酒墙上\n",
      "43 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "42 bottles 在啤酒墙上\n",
      "42 bottles 在啤酒墙上\n",
      "42 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "41 bottles 在啤酒墙上\n",
      "41 bottles 在啤酒墙上\n",
      "41 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "40 bottles 在啤酒墙上\n",
      "40 bottles 在啤酒墙上\n",
      "40 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "39 bottles 在啤酒墙上\n",
      "39 bottles 在啤酒墙上\n",
      "39 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "38 bottles 在啤酒墙上\n",
      "38 bottles 在啤酒墙上\n",
      "38 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "37 bottles 在啤酒墙上\n",
      "37 bottles 在啤酒墙上\n",
      "37 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "36 bottles 在啤酒墙上\n",
      "36 bottles 在啤酒墙上\n",
      "36 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "35 bottles 在啤酒墙上\n",
      "35 bottles 在啤酒墙上\n",
      "35 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "34 bottles 在啤酒墙上\n",
      "34 bottles 在啤酒墙上\n",
      "34 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "33 bottles 在啤酒墙上\n",
      "33 bottles 在啤酒墙上\n",
      "33 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "32 bottles 在啤酒墙上\n",
      "32 bottles 在啤酒墙上\n",
      "32 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "31 bottles 在啤酒墙上\n",
      "31 bottles 在啤酒墙上\n",
      "31 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "30 bottles 在啤酒墙上\n",
      "30 bottles 在啤酒墙上\n",
      "30 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "29 bottles 在啤酒墙上\n",
      "29 bottles 在啤酒墙上\n",
      "29 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "28 bottles 在啤酒墙上\n",
      "28 bottles 在啤酒墙上\n",
      "28 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "27 bottles 在啤酒墙上\n",
      "27 bottles 在啤酒墙上\n",
      "27 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "26 bottles 在啤酒墙上\n",
      "26 bottles 在啤酒墙上\n",
      "26 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "25 bottles 在啤酒墙上\n",
      "25 bottles 在啤酒墙上\n",
      "25 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "24 bottles 在啤酒墙上\n",
      "24 bottles 在啤酒墙上\n",
      "24 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "23 bottles 在啤酒墙上\n",
      "23 bottles 在啤酒墙上\n",
      "23 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "22 bottles 在啤酒墙上\n",
      "22 bottles 在啤酒墙上\n",
      "22 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "21 bottles 在啤酒墙上\n",
      "21 bottles 在啤酒墙上\n",
      "21 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "20 bottles 在啤酒墙上\n",
      "20 bottles 在啤酒墙上\n",
      "20 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "19 bottles 在啤酒墙上\n",
      "19 bottles 在啤酒墙上\n",
      "19 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "18 bottles 在啤酒墙上\n",
      "18 bottles 在啤酒墙上\n",
      "18 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "17 bottles 在啤酒墙上\n",
      "17 bottles 在啤酒墙上\n",
      "17 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "16 bottles 在啤酒墙上\n",
      "16 bottles 在啤酒墙上\n",
      "16 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "15 bottles 在啤酒墙上\n",
      "15 bottles 在啤酒墙上\n",
      "15 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "14 bottles 在啤酒墙上\n",
      "14 bottles 在啤酒墙上\n",
      "14 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "13 bottles 在啤酒墙上\n",
      "13 bottles 在啤酒墙上\n",
      "13 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "12 bottles 在啤酒墙上\n",
      "12 bottles 在啤酒墙上\n",
      "12 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "11 bottles 在啤酒墙上\n",
      "11 bottles 在啤酒墙上\n",
      "11 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "10 bottles 在啤酒墙上\n",
      "10 bottles 在啤酒墙上\n",
      "10 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "9 bottles 在啤酒墙上\n",
      "9 bottles 在啤酒墙上\n",
      "9 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "8 bottles 在啤酒墙上\n",
      "8 bottles 在啤酒墙上\n",
      "8 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "7 bottles 在啤酒墙上\n",
      "7 bottles 在啤酒墙上\n",
      "7 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "6 bottles 在啤酒墙上\n",
      "6 bottles 在啤酒墙上\n",
      "6 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "5 bottles 在啤酒墙上\n",
      "5 bottles 在啤酒墙上\n",
      "5 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "4 bottles 在啤酒墙上\n",
      "4 bottles 在啤酒墙上\n",
      "4 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "3 bottles 在啤酒墙上\n",
      "3 bottles 在啤酒墙上\n",
      "3 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "2 bottles 在啤酒墙上\n",
      "2 bottles 在啤酒墙上\n",
      "2 bottles 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "1 bottle 在啤酒墙上\n",
      "1 bottle 在啤酒墙上\n",
      "1 bottle 啤酒\n",
      "拿一瓶\n",
      "传递它\n",
      "没有更多的啤酒在啤酒墙上了，这瓶不给你，要展示的\n"
     ]
    }
   ],
   "source": [
    "word = \"bottles\"\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num, word,\"在啤酒墙上\")\n",
    "    print(beer_num, word,\"啤酒\")\n",
    "    print(\"拿一瓶\")\n",
    "    print(\"传递它\")\n",
    "    if beer_num == 1:\n",
    "        print(\"没有更多的啤酒在啤酒墙上了，这瓶不给你，要展示的\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\"\n",
    "        print(new_num, word, \"在啤酒墙上\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8a7847c9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
